/*
 * @Description:
 * @Author: Zzt
 * @Date: 2022-08-18 13:44:14
 * @LastEditTime: 2022-08-18 15:19:12
 */
import { createContext, useReducer, useEffect, useContext } from 'react';
import { SET_SELECT_AT, SET_SELECT_FOND_ID, SET_SELECT_AT_ID } from '../constants';
import { RestoreReducer } from '../reducers/RestoreReducer';
const initialState = {};
const RestoreContext = createContext();
const RestoreContextProvider = (props) => {
  const [state, dispatch] = useReducer(RestoreReducer, initialState);
  const actions = {
    /**
     * @description: 设置选中的档案类型
     */
    setSelectAT(data) {
      dispatch({ type: SET_SELECT_AT, data });
    },

    /**
     * @description: 设置选中的全宗
     */
    setSelectFondId(id) {
      dispatch({ type: SET_SELECT_FOND_ID, id });
    },

    /**
     * @description: 设置选中的档案类型ID
     */
    setSelectATId(id) {
      dispatch({ type: SET_SELECT_AT_ID, id });
    }
    // details(data){

    // }
  };
  useEffect(() => {}, []);
  return (
    <RestoreContext.Provider value={{ ...state, ...actions }}>
      {props.children}
    </RestoreContext.Provider>
  );
};
export const useRestoreContext = () => {
  return useContext(RestoreContext);
};
export { RestoreContext, RestoreContextProvider };
